package com.robot.mirai.config.listener;

import com.robot.mirai.controller.interview.listener.SeekersEventListener;
import jakarta.annotation.Resource;
import kotlinx.coroutines.CompletableJob;
import lombok.extern.slf4j.Slf4j;
import net.mamoe.mirai.Bot;
import net.mamoe.mirai.event.EventChannel;
import net.mamoe.mirai.event.GlobalEventChannel;
import net.mamoe.mirai.event.Listener;
import net.mamoe.mirai.event.events.BotEvent;
import net.mamoe.mirai.event.events.MessageEvent;
import net.mamoe.mirai.message.data.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @author ruoLi
 * 全局消息监听
 */
@Slf4j
@Configuration
public class GlobalEventChannelListener {
    private Message message;
    @Resource
    private Bot bot;
    public GlobalEventChannelListener() {
        log.info("创建全局监听事件对象：GlobalEventChannelListener");
    }

    public Listener<MessageEvent> getEventChannelListener(){
        return bot.getEventChannel().subscribeAlways(MessageEvent.class, event -> {
            message = event.getMessage();
            log.info(message.toString());
        });
    }
}
